package com.karlis.controller;

import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.ui.ModelMap;


@Controller
public class WelcomeController {
            @RequestMapping(value="/login.do", method = RequestMethod.GET)
            public String printWelcome(ModelMap model) {
            	User user = (User)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        		String name = user.getUsername();
        	
        		model.addAttribute("username", name);
        		model.addAttribute("message", "Spring Security login + database example");
        		return "welcome";
            }
}
